package com.example.aacwebdemo.es2;


import java.util.ArrayList;
import java.util.Random;

/**
 * @author zhao.xin06679
 * @date 2021年07月02日 14:51
 */
public class RadmonString {

    public static ArrayList<String> strList = new ArrayList<String>();
    public static Random random = new Random();
    public static final int RANDOM_LENGTH1 = 256;
    public static final int RANDOM_LENGTH2 = 512;
    public static final int RANDOM_LENGTH3 = 1024;

    static {
        init();
    }

    public static void main(String[] args) {
        String randomStr = generateRandomStr(RANDOM_LENGTH1);
        System.out.println(RANDOM_LENGTH1 + "位随机数:" + randomStr);
        randomStr = generateRandomStr(RANDOM_LENGTH2);
        System.out.println(RANDOM_LENGTH2 + "位随机数:" + randomStr);
        randomStr = generateRandomStr(RANDOM_LENGTH3);
        System.out.println(RANDOM_LENGTH3 + "位随机数:" + randomStr);
        System.out.println(Long.MAX_VALUE);
    }

    public static String generateRandomStr(int length) {
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i < length; i++) {
            int size = strList.size();
            String randomStr = strList.get(random.nextInt(size));
            sb.append(randomStr);
        }
        return sb.toString();
    }

    public static void init() {
        int begin = 97;
        //生成小写字母,并加入集合
        for(int i = begin; i < begin + 26; i++) {
            strList.add((char)i + "");
        }
        //生成大写字母,并加入集合
        begin = 65;
        for(int i = begin; i < begin + 26; i++) {
            strList.add((char)i + "");
        }
        //将0-9的数字加入集合
        for(int i = 0; i < 10; i++) {
            strList.add(i + "");
        }
    }


}
